TA Computer AI fix
By: David Sellick (email at Switeck@hotmail.com)

Please send comments, ai profiles, and/or a hacked antinuke that the ai can use to my email address.

Special thanks to:

Andrew Griffin - who wrote "Total Annihilation Skirmish AI Profile Notes"
			and the Skirmai06.zip program.
Joe D (joed@cws.org) - who made HPI viewer and HPI packer.
and the many people who have helped me beta-test my ai profiles!

I couldn't have made this possible without you!

(AI stands for artificial intelligence. It refers to the computer-controlled players in skimish games AND multiplayer games with computer players added.)

The ai in Total Annihilation was quite dismal in versions 1.0 and 1.1, and only slightly better in v1.2b1. With the v2.0b1 patch, the ai was improved but still not much of a threat in a 1 vs 1 ai game against a good player. Cavedog has considered improving the ai to be a low-priority goal in patches, and it's looking like the v2.0b1 patch may be the best ai that cavedog makes.

In the absence of an offical Cavedog fix to the Ai problems, we can design our own AI profiles which influences many things that the computer does. The main AI problem is that over 20 units cannot be used by the ai in an intelligent manner. The ai will build 10+ radars right next to each other, or build metal makers when out of both metal AND energy.

My AI profiles tries to fix the most obvious and worst of the problems by eliminating useless (to the Ai only!) units and building AND balancing the numbers of other units built as neccessary.

NO LONGER will the ai try to flash rush you on a sea/island map!
Unfortunately, no longer will the ai build nukes and antinukes since it never seemed to use them anyway.

Just by eliminating the useless units (to the ai only!) my ai should be a vast improvement over what cavedog has made.

TO INSTALL THESE FILES:
----------------------

To use my ai profile text files you must place the text files in the AI directory.

What! You don't have an AI directory? Create one!
The AI directory goes under the TOTALA directory like so:
C:\CAVEDOG\TOTALA\AI

Nothing else is required to use this file.

I'm constantly working on improvements and refinements on the AI's build strat, so the file I send you today probably won't be the one I use tommorrow. The SEABATTLE.TXT ai profile is very similar to the AIRBATTLE.TXT ai profile, both presume that their bases are separated from yours by water.

NOTE:
----

** THE DIFFICULTY SETTING FOR MULTIPLAYER AI'S USES THE DIFFICULTY SETTING IN SKIRMISH! **
To make the multiplayer ai use the hard setting, go into skirmish and set the difficulty to the hard setting. Then, you must actually start a skirmish mission (and self-destruct to end the skirmish) with those settings before TA will remember them.

The ai on the easy setting should prove MUCH less of a challenge than it is on hard.
This ai presumes a map with SOME resources on it, and max unit limit of at least 150.
If the ai has less than 1000 starting resources, it may not build anything.
On maps with very limited building space, the ai will build slowly if at all.
The ai doesn't think about building locatioins - and may wall itself in on accident!
The ai is not equipped to defend against an all-out rush very early in the game.
(Most players aren't, why should the ai be any different?)

I DO NOT CLAIM THAT THIS AI IS A SUPER-UNBEATABLE OPPONENT!
It is an improvement over the original ai, not the answer to all the world's problems.

Also, please notice that some of the ai profiles may/may not have different version numbers. Ussually, the different ai profiles are all made from either Default (land battle ai) or SeaBattle (naval ai) and the version number tells which version of Default/SeaBattle ai that the other ai profiles were made from.


Changes to the ai profiles: (if not mentioned, for default only)
0.1 copied ai files in TOTALA1.HPI and removed the metal makers
 NOTE: never actually existed except in concept!
I knew metal makers were the major ai problem because I only played metal maps, at first.
0.5 This ai profile is patterned like a friend (who won most games) of mine played
 NOTE: This file was originally called Ken.txt, it has not been tested. It only uses weights.
1.0 eliminated a great many units and greatly limited others
2.0 copied my seabattle ai and started over, which was considerably advanced over the others
2.5 removed the weight level2 and level3 lines because of the problems they caused
2.8 balanced every factory individually
3.0 reduced the max number of buildings to prevent large base but no army problem at unit max
3.3 tried to get all the attack units weighted and limited
3.4 trying to find the proper weights and limits for each factory and c-unit types
 NOTE: total removal of naval units in Default ai! Also, first ai to have a version #.
3.5 modest changes on almost everything the ai makes - should prove interesting...
4.0 total about-face on my ai once it (v3.5) lost to earlier version (3.4)
4.1 rebalancing of factories and the like.
4.2 rearranged my Default.Txt file on the assumption that the order affects weights.
4.3 rearranged ALL ai profiles on the assumption that the order affects weights.
5.0 Same as v4.3 with all the weights placed before limits on units. Some other little changes.
5.1 v5.0 built 7 solars and 7 metal extractors before a factory, That should be fixed in v5.1!
5.2 minor changes, barely meriting a new version #...
5.3 just by increasing the weight on the factories, the ai seemed more aggressive
5.4 still has the slow-start problem v5.0 had (but not nearly as bad) - no early factories!
6.0 represents the first conversion of the ai to TA:CC
6.1 almost every unit is limited now, since total unit types is greater than unit max!
6.2 more modest changes in unit limits and weights.
6.5 flash rush ai for ARM, removing both kbot labs and aircraft plants
6.6 flash rush ai modified to include aircraft plants and even kbot labs on nonmetal maps
6.7 more modest changes in unit limits and weights.
6.8 more modest changes in unit limits and weights.
7.0 The commander-only early build strategy didn't work so well, so early c-units added back.
7.1 Forgot to put a weight on Moho Metal Makers. No wonder the ai's attacks slowed!
7.2 - 7.9 weight/limit problems on solars, metal extractors, factorys, and C-units.
8.0 Is v7.1 reworked to use metal makers (max of 4).
8.1 lowered the number of base buildings that can be built (was always out of metal).
8.2 further reduced the number of base buildings that can be built (was STILL out of metal).

SETBACKS: (basically which versions are better or worse)
v2.5 was obviously better than the original ai in v2.0b1
v3.4 was really good, and I didn't realize that later versions were just watering it down.
v4.2 and v4.3 might be even better than v3.4
v5.1 looks promising, once I sort out what weights my factories and metal extractors needs
v5.2 is better than v3.4 or v4.3
v5.3 seems an improvement over v5.2
v6.0 was considerably weaker than even v3.4 (first for TA:CC)
v6.1 and v6.2 are better than v6.0
v6.5 made an earlier attack, but a very simple one (Flashes and Samsons)
v6.6 const. aircraft act as a booster for production for low cost, about as good as v5.3
v6.7 better than all the above
v7.0 represents probably the first default ai to give me any sort of challenge
v7.1 considerably better than all the above!
v7.2 - v7.9 were all setbacks, I'd lost which ai seemed to have the best build strats
v8.0 surprisingly, the ai can use small numbers of metal makers in the v3.1 patch!
v8.1 is good on attack but still poor on ground defense.
v8.2 is at least as good as v7.1


All you wanted to know about ai's but were afraid to ask:

    What has improve since v3.4?
I haven't improved much, just trying to find ways for the ai to get attack units out a few seconds earlier. BUT without having to hit 0 metal doing it. got to have early metal extractors but not build them then forget to build factories. cannot neglect solars. and have to have early construction units to keep the production increasing. And everyone thinks flash rushes is just flash tanks! My goal is to make the ai more focused, using fewer unit types which are better for a particular map type. This may make the ai more boring, but more effective.

    There seems to be 3 units whose weight and limit must be carefully balanced. These are: solar panel, metal extractor, and the vehicle plant. These 3 units are the gateway to getting ALL other units, and must be built as early as possible.

    Most maps fall under the standard general categories of Default, SeaBattle, AirBattle, and Metal - but the really interesting ones need specific ai profiles made just for them. An extreme example is an all-water map with very little land. Seabattle assumes that there is land to build a good sized land base on, particularly solars, metal extractors, hovercraft and aircraft plants. Lacking that, the ai will build very slowly - if at all - and will be easily beaten. The basic ai profiles categories are too vague to cover many types of maps. In the mapmaking process, things to consider when choosing an ai profile type (even if it doesn't exist!) are:
1.How large is the map? (can't flash rush effectively on a 30 x 30 land map)
2.How much water (by percent) is the map? (possibly a naval ai map?)
3.Is the land and water alternating making either form of attack difficult or impossible?
4.How plentiful is metal on this map?
5.Is there any geothermal vents on the map?
6.How flat/hilly is the map?
7.Are trees so thick that they must be reclaimed to have room to build?
8.Is there lots of reclaimable rocks around?
9.Does the map have consistantly high winds or gusty winds?
10.Because of some feature on the map, does one particular unit (or type) have a significant advantage over the others? (such as narrow land passes, steep slopes, or thick trees)

1.An example of a large map that isn't a typical default ai profile is Greenhaven. It's TOO big for a flash rush to reach an enemy base early enough to make winning easy. Such a map may require the ai to build slightly more base defenses than usual and rely on long-ranged attack types (Merls, Berthas, aircraft) to effectively destroy the enemy base.
2.Gods of War is a good example of a some-land, lot-water map that's well suited for a naval ai.
3.The best examples of this is Over Crude Water (a metal map) or Evad River Confluence. Both maps have water acting as a barrier to large land attacks. Neither a land attack or naval attack can easily reach the enemy base. This forces relying on hovercraft and aircraft to strike the enemy base. So they're both air battle ai's.
4.Some maps have so little metal - such as Painted Desert - that the ai either must spread out all over the map or build metal makers. And the ai cannot manage metal makers very well, always wanting to build way more metal makers than it has energy to run. Also, its construction units will suicidally wander into enemy bases trying to build a metal extractor on unused metal spots.
5.Geothermal plants are vital stepping stones to getting fusion reactors for players, but for the ai who shouldn't build such an energy-hungry base they are even MORE vital. An ai can have a large base totaling 50 buildings and only need 15 solars and 2 geo's to run it. On nonmetal maps, where only 1 geo can be built on a vent, the ai should have a max limit of 2 to 6 geothermal plants (depending on the total number of vents on the map) so that it doesn't wastefully and suicidally send its construction units into the enemy territory to build a geo on thermal vents there. On metal maps, the max limit on geos can be as high as 10 without any problems, because up to 4 geothermal plants can be built on each vent.
6.A very hilly map makes for lots of killzones and choke points that by the middle of the game render ground forces useless. Plus a hilly map may have very little room to build a base. A few short-ranged LLT's and guardians are best as base defenses because line-of-sight is so restrictive. The guardians can shoot over some of the hills, and the LLT's can guard passes and enterances to bases.
7.Maps with wall-to-wall trees make big bulky units less useful, so often the level 1 kbots and aircraft are the only units that can get around effectively.
8.Unless there's so many rocks that they are in the way, this has little effect on an ai. However once the commander goes into repair and reclaim patrol mode, the rocks may be the only thing that keeps the ai's factories producing more units.
9.Wind generators should be used instead of solars if the wind is consistantly strong, or half solars half wind generators if the wind gusts are strong enough (like +20 or more energy).
10.Metal Isles has large islands with very tall defensive walls. Although a huge naval force may take control of the water around the island, it will be unable to shoot into the middle of the island with cruisers and battleships because of the size of the island and the high walls. Missile frigates are more useful for attacking such bases, but cannot be made the bulk of the naval force or it will surely lose to a naval force made primarily of cruisers and battleships. Also, since the map is rather large, significant amounts of anti-aircraft ships are needed with the naval force.
The flash tank excels on Metal Heck - it is fast and cheap, allowing for early base attacks. Plus it is small, making it hard to hit and better able to move around debris.


    With the addition of TA:CC, all the new units that CAN be built tend to "water down" the ai. A BIG problem is the unit count, with 70+ new units it is impossible for the ai to build a reasonable number of any particular unit. As my SETBACKS section suggests, every time I eliminate units so the ai no longer builds them, the ai generally gets better. V6.0 was my first attempt to build a proper ai for TA:CC. It was only halfway a success and proved to build very slowly and its first attack was both later and smaller than similar ai's made for TA v2.0b1.

    The unit max in a game is typically 250 (with the v2.0b1 patch and v3.0). This is a limitation unlike any other, because once the ai reaches 250 units (and it used to do so somewhere between the 20 and 30 min mark, if not beaten senseless) it becomes stupid. As it loses units, for every 3 mobile units it loses, it tends to replace them with 1-3 new buildings. This causes the total available mobile units to decrease and its base to grow larger and larger. Eventually, the ai gets where it doesn't want to fight at all - because it has VERY FEW potiential attacking units. Lowering the unit max causes this to happen earlier and be more severe, where a unit max of around 40 or less might prevent the ai from ever attacking. Raising the unit max helps, but at 500 unit max the ai doesn't build a base as LARGE as a player might at 500 unit max. The ai doesn't know what the unit max is, NOR does it reclaim its less-useful units to prevent hitting the limit, NOR does it start building or stop building ANYTHING just because it is near unit max. This is why EVERY base building the ai CAN build must have a max limit.

    Back in v2.5, I removed the weight LEVEL2 6 and weight LEVEL3 3 lines from the ai profiles. It SEEMED like a good idea to have them in there, BUT these lines were totally ruining the ai. This is because almost everything is either level 1, 2, or 3. So if an unit didn't have a weight on it was given a very high weight because of these blanket values. (covering ALL level2 and level3 units!)

    There *IS* some building strategies built directly into the executable that runs TA. Even when an ai profile is blank, the ai will still follow some criteria:

1.Starting out, regardless of ai profile settings, the ai STRONGLY wants to build some metal extractors and solar panels. This can be to the ai's detriment on metal maps with 10k resources, since most players build a factory first with such excessive resources.
2.If the ai stays low on energy or metal, it will (eventually) try to build some units to fix that problem. Unfortunately, it thinks that metal makers will fix its problem when at 0 energy and all its metal extractors (and other metal makers) quit working. The ai at that point sees the problem as a lack of metal production instead of a lack of energy.
3.The ai builds its buildings along an invisible grid, with clumps of buildings together separated by empty areas or "roads" between them. This is MOST noticeable on open metal maps, like Metal Heck or Metal Isles.
4.The ai's commander is only thought of as a construction unit until its first or second construction unit is built. After that, the commander walks around in a loop (on patrol), occassionaly assisting any nearby building projects it runs accross. It also repairs damaged units and reclaims any handy metal or energy laying around near its path. It has not, as some have suggested, just "gone dumb" and started walking around in circles. This is done to prevent the massive resource drain the commander can cause by constantly building, while still allowing him to be useful occassionally.
5.If energy drops below 100, metal extractors and metal makers (this includes the moho metal makers) quit producing metal but do NOT quit draining energy! This is why the ai must be restricted from building metal makers, since if it has more metal makers than it can sustain, it will stay near 0 energy. It will be unable to d-gun, use its lasers, and it will USSUALLY not start new building projects that require a lot of energy.
6.The ai actually shuts off the moho metal makers (and perhaps the metal makers as well) if it is full of metal and is still making more than it needs. This often happens when the ai reaches unit max, and can actually be benificial since it lets energy build back up - to be used to finish building energy-expensive units and so it can fire energy-draining weapons (such as berthas) more rapidly.
7.The ai attacks with its ground units when it gets around 8 or more ground units. Sometimes this number is as low as 5, other times it's as high as 20. The ai's attack force is ussually in 1 group, and attacks until no more than 10 units are left. Then the attack force retreats to base until it can be rebuilt.
8.The ai's ground attack force (this seems to include hovercraft) try to stay together, so this means if the ai has *ANY* non-amphibious units in the attack force then the amphibious units will wander around in the water waiting for other units to catch up. (even though they can't!) Ships and aircraft are handled in a separate group and can move independantly of the ground units. I call this the "Wait for me!" bug where the attacking units turn around to let a newly-created unit catch up with the attack force. Once the attack force is committed to combat (ie - shooting at something), normally this doesn't happen.
9.The ai's Aircraft wander the map aimlessly in a loose group until they find something to kill. Then they ussually continue attacking the one target until they or it are destroyed. After that, they continue wandering aimlessly. This is actually a very large patrol path, and as such if the aircraft get severely damaged, they often seek an air repair pad or light carrier to repair themselves on. Once repaired, they rejoin the group.
10.How spread out the ai's base is depends on the terrain. Mainly, it's how far the construction units have to wander to find metal extractors. This also means that metal extractors often get some defenses around them and factories built near them. On a metal map like Metal Heck, the ai makes a small, tightly-packed base. On Greenhaven, the ai's base is considerably more spread out. On Painted Desert (where metal spots are often over 1 screen apart), the ai's base looks like little patches all over the map if given enough time to build it.
11.The ai is aqua-phobic, and if it doesn't start right on the water's edge it is VERY slow about building a shipyard even if the shipyard is weighted VERY high! Construction Aircraft aren't as afraid of the water as other construction units, this is probably because of their high speed - the water isn't as far away from them. (Also maybe it's because they don't worry about getting wet?)
12.Because of the map, the ai may LAUNCH an attack early (like the 5 min mark) but take a large amount of time to reach an enemy's base. In earlier versions of TA (like v1.2), the best example of this was when it tried to send its ground forces to your base on a water map.